package com.vodafone.mapreduce.dto.function;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.vodafone.mapreduce.MapReduce;

/**
 * Input for the reduce function.
 * 
 * @param <K>
 * @param <V>
 * @param <L>
 * @param <W>
 */
public class ReduceInput<L, W> implements Serializable {

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Class constants.
    // -------------------------------------------------------------------------------------------------------------------------------------

    private static final long serialVersionUID = MapReduce.SERIAL_VERSION_UID;

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance attributes.
    // -------------------------------------------------------------------------------------------------------------------------------------

    private final Map<L, List<W>> intermediate;

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance constructors.
    // -------------------------------------------------------------------------------------------------------------------------------------

    public ReduceInput(Map<L, List<W>> intermediate) {
        this.intermediate = intermediate;
    }

    // -------------------------------------------------------------------------------------------------------------------------------------
    // Instance methods.
    // -------------------------------------------------------------------------------------------------------------------------------------

    public Map<L, List<W>> getIntermediate() {
        return Collections.unmodifiableMap(intermediate);
    }

    public String toString() {
        return "intermediate:" + intermediate.toString();
    }

    // -------------------------------------------------------------------------------------------------------------------------------------

}
